package com.asiainfo.fc.ui;

import java.awt.Color;
import java.awt.FlowLayout;
import java.util.ArrayList;

import javax.swing.JPanel;

import com.asiainfo.fc.util.StringHelper;

public class RedBluePanel extends JPanel {

	/**
	 * RedBluePanel
	 */
	private static final long serialVersionUID = 5603861765831477864L;
	private ArrayList<ColorButton> btList;

	public RedBluePanel(String strRedBlue) {
		btList = new ArrayList<ColorButton>();
		int[] redBlueArr = StringHelper.toRedBlueArray(strRedBlue);
		this.setLayout(new FlowLayout(1, 1, 1));
		for (int i = 0; i <= 5; i++) {
			ColorButton readButton = new ColorButton(Color.red, redBlueArr[i]);
			this.add(readButton);
			btList.add(readButton);
		}
		ColorButton readButton = new ColorButton(Color.blue, redBlueArr[6]);
		btList.add(readButton);
		this.add(readButton);
	}

	/**
	 * 
	 * @param strRedBlue
	 */

	public void UpdateText(String strRedBlue) {
		if (!strRedBlue.equals("")) {
			int[] redBlueArr = StringHelper.toRedBlueArray(strRedBlue);
			for (int i = 0; i <= 5; i++) {
				btList.get(i).Update(Color.red, redBlueArr[i]);
			}
			btList.get(6).Update(Color.blue, redBlueArr[6]);
			repaint();
		}
	}

}
